<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html ng-app="LeaderboardApp">
<head>
<meta charset="UTF-8">
<title>Administración de Asistencias de Empleados a Farmacias</title>
<link href="/Leaderboard/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="/Leaderboard/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="/Leaderboard/css/bootstrap-spinner.css" rel="stylesheet" type="text/css"/>
<link href="/Leaderboard/css/select2.css" rel="stylesheet" type="text/css"/>
<link href="/Leaderboard/css/select2-bootstrap.css" rel="stylesheet" type="text/css"/>
<link href="/Leaderboard/css/styles.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript" src="/Leaderboard/js/lib/bootstrap/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/Leaderboard/js/lib/bootstrap/respond.min.js"></script>
<script type="text/javascript" src="/Leaderboard/js/lib/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="/Leaderboard/js/lib/bootstrap/bootstrap3-typeahead.js"></script>
<script type="text/javascript" src="/Leaderboard/js/lib/bootstrap/jquery.spinner.min.js"></script>
<script type="text/javascript" src="/Leaderboard/js/lib/bootstrap/jquery.blockUI.js"></script>

<!--[if lt IE 9]><script type="text/javascript" src="/Leaderboard/js/lib/angularjs/html5shiv-printshiv.min.js"></script><![endif]-->
<!--[if lt IE 8]><script type="text/javascript" src="/Leaderboard/js/lib/angularjs/json3.min.js"></script><![endif]-->

<script type="text/javascript" src="/Leaderboard/js/lib/select2.min.js"></script>
<script type="text/javascript" src="/Leaderboard/js/lib/angularjs/angularjs-1.2.16.min.js"></script>
<script type="text/javascript" src="/Leaderboard/js/controllers.init.js"></script>
<script type="text/javascript" src="/Leaderboard/js/controllers.admin.js"></script>
<script type="text/javascript" src="/Leaderboard/js/controllers.asistencias.js"></script>

<!--[if lte IE 8]>
<script type="text/javascript">
    $(document).ready(function() {
        angular.bootstrap(document);
    });
</script>
<![endif]-->
</head>
<body>
	<div ng-include="'/Leaderboard/include/header.html'"></div>
	
	<div class="container">
		<div ng-include="'/Leaderboard/include/changePassword.html'"></div>
	
		<div ng-controller="asistenciasCtrl">
			<div ng-include="'/Leaderboard/include/messages.html'"></div>
			<div class="panel panel-primary">
				<div class="panel-heading"><h3 class="panel-title">Administraci&oacute;n de Asistencias de Empleados a Farmacias</h3></div>
				<div class="panel-body panel-body-scrollable">
					<form role="form" class="form-horizontal">
						<div class="form-group">
							<label class="col-sm-3 control-label">Seleccionar mes</label>
							<div class="col-sm-6">
								<select ng-change="getAsistencias()" ng-options="mes.label for mes in mesesAsistencias" ng-model="mesSeleccionado" class="form-control ng-pristine ng-valid" name="meses" id="cmbMeses"></select>
							</div>
						</div>
					</form>
				
					<table class="table table-striped table-condensed table-bordered" ng-table="tableParams">
						<thead><tr><th>ID</th><th>Empleado</th><th >Mes</th><th class="number-column">Dias Asistencia</th><th>Sucursal</th><th colspan="2">Acciones</th></tr></thead>
						<tbody><tr ng-repeat="asist in asistencias | filter:asistsSearch">
							<td>{{asist.id}}</td><td>{{asist.userEmp}} - {{asist.userName}}</td><td>{{asist.monthLabel}}</td><td class="number-column">{{asist.days}}</td><td>{{asist.branchName}}</td>
							<td>
								<span>
									<a class="link float-left" href="javascript:void(0);" ng-click="openAsistDialog('edit', asist)">Editar</a>
									&nbsp;
									<a class="link float-left" href="javascript:void(0);" ng-click="delAsistencia(asist.id)">Borrar</a>
								</span>
							</td>
						</tr></tbody>
					</table>

				</div>
				<div class="panel-footer">
					<input id="asistsSearch" name="asistsSearch" class="form-control search-box" ng-model="asistsSearch" placeholder="Escriba el texto a buscar" />
					<button type="button" class="btn btn-default" ng-click="getMesesAsistencias()">Refrescar</button>
					<button type="button" class="btn btn-primary" ng-click="openAsistDialog('add', null)">Agregar nueva</button>
				</div>
			</div>
	
			<div class="modal fade" id="dlgAddEditAsist" role="dialog" aria-labelledby="dlgAddEditAsist" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<form id="addAsistForm" name="addAsistForm" class="form-horizontal" role="form">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">Agregar/Editar Asistencia</h4>
							</div>
							<div class="modal-body">
								<div ng-include="'/Leaderboard/include/modalMessages.html'"></div>
								<div class="form-group">
									<label for="txtUsuario" class="col-sm-4 control-label">Usuario</label>
									<div class="col-sm-8">
										<input id="txtUsuario" name="usuario" class="form-control" type="text" maxlength="150" width="150" 
												ng-model="addAsistData.userName" autofocus required ng-disabled="loading || editAsistMode" ng-change="getCurrentBranchUser()" autocomplete="off" autofocus />
									</div>
								</div>
								<div class="form-group" ng-hide="editAsistMode">
									<label for="lblSucActual" class="col-sm-4 control-label">Sucursal actual</label>
									<div class="col-sm-8"><span id="lblSucActual" class="form-control">{{currentBranch}}</span></div>
								</div>
								<div class="form-group">
									<label for="cmbAddEditMes" class="col-sm-4 control-label">Mes</label>
									<div class="col-sm-8">
										<select ng-change="getAsistencias()" ng-options="mes.label for mes in mesesAsistencias" ng-model="addAsistData.month" class="form-control ng-pristine ng-valid" name="meses" id="cmbAddEditMes" required></select>
									</div>
								</div>
								<div class="form-group">
									<label for="txtDiasAsistencia" class="col-sm-4 control-label">D&iacute;as asistencia</label>
									<div class="col-sm-8 input-append spinner" data-trigger="spinner">
										<input id="txtDiasAsistencia" name="ponderacion" class="form-control" type="text" maxlength="3" width="3" 
												ng-model="addAsistData.days" required ng-disabled="loading" data-rule="percent" />
									</div>
								</div>
								<div class="form-group">
									<label for="cmbSucursal" class="col-sm-4 control-label">Sucursal destino</label>
									<div class="col-sm-8">
										<select id="cmbSucursal" name="sucursal" class="form-control" ng-model="addAsistData.branch" ng-options="branch.name for branch in branches | filter:{name:'!TODAS'}" required ng-disabled="loading">
										</select>
									</div>
								</div>
								<div class="form-group" ng-hide="editAsistMode">
									<div class="col-sm-offset-4 col-sm-8">
										<div class="checkbox">
											<label><input type="checkbox" id="chxCambioPermanente" ng-model="addAsistData.permanent" /> Cambio permanente </label>
										</div>
									</div>
								</div>
								
							</div>
							 <div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
								<button type="submit" class="btn btn-primary" ng-click="saveAsistencia()" ng-disabled="loading || addAsistForm.$invalid">Guardar cambios</button>
							</div>
						</form>
					</div>
				</div>
			</div>
			
		</div>
	</div>
</body>
</html>